# Maintainer: Bjoern Lemke <lemke@lemke-it.com>

_realname=lfcxml
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.3.2
pkgrel=1
pkgdesc="LFC C++ xml classes (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url='http://www.lemke-it.com/'
license=('GPL3')

source=("http://www.lemke-it.com/${_realname}-${pkgver}.tar.gz")

depends=("${MINGW_PACKAGE_PREFIX}-lfcbase")

sha256sums=("0c5a263cd2c82d137e97b510ba2f8b0408e4ef3e08954e5876c5d956ca65b0c4")

prepare() {
  cd $srcdir/${_realname}-${pkgver}
}

build() {
  cd "$srcdir"/${_realname}-${pkgver}
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make

  ${MINGW_PREFIX}/bin/gcc -shared \
    -Wl,--out-implib,liblfcxml.dll.a \
    -o liblfcxml-0.dll \
    ${srcdir}/build-${CARCH}/src/*.o \
    -llfcbase -lsystre -lws2_32 -lpthread -lstdc++

}

check() {
  cd "${srcdir}"/build-${CARCH}
  make check
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
  mkdir -p "${pkgdir}"${MINGW_PREFIX}/{bin,lib}
  install -m 0755 liblfcxml-0.dll "${pkgdir}${MINGW_PREFIX}/bin"
  install -m 0644 liblfcxml.dll.a "${pkgdir}${MINGW_PREFIX}/lib"

}
